home *** CD-ROM | disk | FTP | other *** search
/ Gold Medal Software 1 / Gold Medal Software Volume 1 (Gold Medal) (1994).iso / prog / dasv10_.arj / HERODIE.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1993-09-09  |  3.4 KB  |  160 lines

  1. // Super Heros Damage Dice
  2. // and Combat System
  3. #include <iostream.h>
  4. #include <iomanip.h>
  5. #include <process.h>
  6. #include <stdlib.h>
  7. #include <conio.h>
  8. #include <time.h>
  9.  
  10. // function prototypes
  11. int die_hero(int,int,int);
  12. int damage_menu(void);
  13. int main_menu(void);
  14. void line_draw(void);
  15. void detect_damage(int,int);
  16. void display_damage(int,int,int);
  17. void roll_dice(int dice,int damage);
  18.  
  19. void main()
  20. { // begin main program
  21. int dice=0,mdice,damage,mdamage,choice1,choice2;
  22. int status;
  23.  
  24. MAIN_MENU:
  25. while ((choice1 = main_menu()) != 6) { // begin while
  26.         switch (choice1) { // begin menu select
  27.             case 1:
  28.                 goto ENTER_DICE; // change dice
  29.                 break;
  30.             case 2:
  31.                 if (dice==0) // begin if
  32.                     goto MAIN_MENU;
  33.                 // end if
  34.                 goto ROLL_DICE; // roll same dice
  35.                 break;
  36.             case 3:
  37.                 dice=3; damage=2; // 3D6 roll
  38.                 goto ROLL_DICE;
  39.                 break;
  40.             case 4:
  41.                 cout<<endl<<"Auto/Manual dice? (0/1): ";
  42.                 cin>>status;
  43.                 goto MAIN_MENU;
  44.                 break;
  45.             case 5:
  46.                 exit(0); // quit program
  47.                 break;
  48.         } // end menu
  49. } // end while
  50. goto MAIN_MENU;
  51.  
  52. ENTER_DICE:
  53. clrscr(); cout<<"\nPlease enter number of dice (1 - 300) ? ";
  54.         cin>>dice;
  55.         if (dice<1 || dice>300) // begin if
  56.             goto ENTER_DICE;
  57.         // end if
  58.  
  59. DAMAGE_MENU:
  60. while ((choice2 = damage_menu()) != 4) { // begin while
  61.         switch (choice2) { // begin menu select
  62.             case 1:
  63.                 damage=0; // killing damage
  64.                 mdice=dice;    mdamage=damage;
  65.                 goto ROLL_DICE;
  66.                 break;
  67.             case 2:
  68.                 damage=1; // normal damage
  69.                 mdice=dice; mdamage=damage;
  70.                 goto ROLL_DICE;
  71.                 break;
  72.             case 3:
  73.                 goto MAIN_MENU; // main_menu()
  74.                 break;
  75.         }// end menu
  76. } // end while
  77. goto DAMAGE_MENU;
  78.  
  79. ROLL_DICE:
  80. detect_damage(dice,damage);
  81.     if (status==0) // begin if
  82.         cout<<setw(59)<<"[Auto Roll]";
  83.     else // else
  84.         cout<<setw(59)<<"[Space=Roll]";
  85. line_draw();
  86. roll_dice(dice,damage);
  87. dice=mdice; damage=mdamage;
  88.  
  89. goto MAIN_MENU;
  90. }// end main program
  91.  
  92. // function damage_menu()
  93. int damage_menu(void)
  94. {
  95.     int choice2;
  96.  
  97. clrscr();
  98.     cout<<setw(45)<<"Damage Menu";
  99. line_draw();
  100.     cout<<"Please enter a selection:";
  101.     cout<<endl<<" 1 = Killing";
  102.     cout<<endl<<" 2 = Normal";
  103.     cout<<endl<<" 3 = Main Menu ? ";
  104.     cin>>choice2;
  105.     return choice2;
  106. }// end damage_menu()
  107.  
  108. // function main_menu()
  109. int main_menu(void)
  110. {
  111.     int choice1;
  112.  
  113. clrscr();
  114.     cout<<setw(44)<<"Main Menu";
  115. line_draw();
  116.     cout<<"Please enter a selection:";
  117.     cout<<endl<<" 1 = Change Dice";
  118.     cout<<endl<<" 2 = Roll Same Dice";
  119.     cout<<endl<<" 3 = 3D6 Roll";
  120.     cout<<endl<<" 4 = Auto/Manual Dice";
  121.     cout<<endl<<" 5 = Quit Program ? ";
  122.     cin>>choice1;
  123.     return choice1;
  124. }// end main_menu()
  125.  
  126. // function roll_dice()
  127. void roll_dice(int dice,int damage)
  128. {
  129.     int i,col,die,numdie,totaldice=0,normal=0;
  130.     col=dice/10;
  131.     randomize();
  132.  
  133.     for (numdie=1;numdie<=dice;numdie++) { // begin for
  134.         die=die_hero(6,(300-dice)/5,1);
  135.         cout<<die<<" ";
  136.         if (col>1) { // begin if one
  137.             if (numdie % col == 0) // begin if two
  138.             cout<<"<-Rolls #"<<numdie+1-col<<" to "<<numdie-1/col<<endl;
  139.             // end if two
  140.         } // end if one
  141.     if (col<2) // begin if
  142.         cout<<"<-Roll #"<<numdie<<endl;
  143.     // end if
  144.     totaldice+=die;
  145.     if (damage==1 && die==6) // begin if
  146.         normal+=2;
  147.     // end if
  148.     if (damage==1 && die<6 && die>1) // begin if
  149.         normal+=1;
  150.     // end if
  151. } // end for
  152.  
  153. line_draw();
  154. display_damage(damage,normal,totaldice);
  155.  
  156. cout<<setw(39)<<"[Press any key]"<<endl;
  157. getche();
  158. }// end roll_dice
  159.  
  160.